package com.im.test.core;

import com.im.test.bean.LiveRoomBean;
import com.im.test.bean.LiveRoomMessageBean;
import com.im.test.bean.LiveRoomTopRankBean;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class WebSocketMessageListener implements MyWebSocketClinet.MessageListener {

    private int count = 0;

    private long startTime = System.currentTimeMillis();

    private long lastSendTime = System.currentTimeMillis();

    private long lastCount = 0;
    @Override
    public void onMessage(LiveRoomMessageBean i) {
        count++;
    }

    @Override
    public void onSystemMessage(LiveRoomMessageBean i) {
    }

    @Override
    public void onLogin() {

    }

    @Override
    public void roomClose() {

    }

    @Override
    public void enter(LiveRoomMessageBean i) {

    }

    @Override
    public void mute(int i) {

    }

    @Override
    public void getNewMessage() {

    }

    @Override
    public void setManage(int i, LiveRoomMessageBean bean) {

    }

    @Override
    public void killUser() {

    }

    @Override
    public void givingGift(LiveRoomMessageBean bean) {

    }

    @Override
    public void topRank(LiveRoomTopRankBean bean) {

    }

    @Override
    public void liveRoomTab(LiveRoomBean bean, int type) {

    }

    @Override
    public void openNoble(LiveRoomMessageBean givingGiftUserBean) {

    }

    @Override
    public void openGuard(LiveRoomMessageBean givingGiftUserBean) {

    }

    @Override
    public void interactive(LiveRoomMessageBean bean) {

    }

    @Override
    public void hostTask(LiveRoomMessageBean bean) {

    }

    @Override
    public void killRoom() {

    }

    @Override
    public void roomMessage(LiveRoomMessageBean bean) {

    }

    @Override
    public void barrageMsg(LiveRoomMessageBean bean) {

    }

    @Override
    public void focusLiver(LiveRoomMessageBean bean) {

    }

    @Override
    public void globalSystem(LiveRoomMessageBean bean) {

    }

    @Override
    public void switchLine(LiveRoomMessageBean bean) {

    }

    @Override
    public void muteMessage(LiveRoomMessageBean bean) {

    }

    @Override
    public void reconnect() {

    }

    @Override
    public void reconnectFail() {

    }

    public void showLog(){
        try {
            log.info("该连接已连接:{}秒,共收到:{}条消息,每秒收到约:{}条消息",(System.currentTimeMillis()-startTime)/1000,count,Math.ceil((count-lastCount)/((System.currentTimeMillis()-lastSendTime)/1000)));
            lastSendTime = System.currentTimeMillis();
            lastCount = count;
        }catch (Exception e){

        }
    }
}
